/*
 * Lun.cpp
 *
 *  Created on: Dec 15, 2011
 *      Author: Netali
 */

#include <limits>
#include "Lun.h"

// compare to LUNs according to LUN ID
Lun& Lun::operator= (Lun const &l){
		if (this != &l){
			m_uid = l.m_uid;
		}
		return *this;
};

/* input: actual response time for some time slice 
 * output: damage of this lun for that time slice
 */
double Lun::calc_damage(double response_time) {
	double damage = 0;

	if (response_time > desired_response_time){
		damage = (response_time - desired_response_time);
		damage = damage * ((double)1.0/(desired_response_time));
	}

	return damage;
}

void Lun::divide_priority(){
	priority = 1 / (desired_response_time);
}

void Lun::setPriority(double prio) {
	 priority = prio;
}

void Lun::divide_priority_3_groups(){
	if (priorityGroup==1){
		priority = 1000000;
	}
	else if (priorityGroup==2){
		priority = 1000;
	}
	else {
		priority = 1;
	}
}